<?php 
/**
 *
 * @author Administrator
 *
 */
class BlyuyueModel extends Model
{
	//数据表
	protected $trueTableName = 'bl_yuyue';
	
	//设置主键
	protected  $key = 'id';
	
	//获取数据条数
	public function getCount($seek='')
	{
	
		//条件
		$where = '1=1';
	
		return $this->where($seek.$where)->count();
	
	}
	/**
	 * 获取列表
	 * @param unknown $page 分页参数
	 * @param unknown $seek 搜索参数
	 * @return Ambigous <mixed, string, boolean, NULL, unknown, multitype:, multitype:multitype: , void, object>
	 */
	public function getListAll($page, $seek='')
	{
		//字段
		$field = array(
				'*',
		);
	
		//条件
		$where = '1=1';
	//die($seek.$where);
		return $this->field($field)->where($seek.$where)->order('id asc')->limit($page)->select();
	
	}
	/**
	 * 插入一条数据
	 * @param array $data
	 * @return Ambigous <mixed, boolean, string, false, number>
	 */
	public function insert(array $data)
	{
		//字段
		$field = array(
				'id',
				'name',
                'tel',
            	'ks',
                'http_url',
                'yuyuedata',
                'addtime',
                'dy_ip',
                'isdl',
                'cl_time',
                'bz_cont',
                'sex',
                'gre',
                'ag_cont',
                
		);
			
		//字段过滤
		$data = $this->CheckField($data, $field);
		$data['addtime'] = date("Y-m-d H:i:s",intval(time()));
		//添加时间
	
		return $this->add($data);
			
	}
	/**
	 * 更新一条数据
	 */
	public function update(array $data, $id)
	{
	
		//字段
		$field = array(
				'id',
				'name',
                'tel',
            	'ks',
                'http_url',
                'yuyuedata',
                'addtime',
                'dy_ip',
                'isdl',
                'cl_time',
                'bz_cont',
                'sex',
                'gre',
                'ag_cont',
		);
	
		//字段过滤
		$data = $this->CheckField($data, $field);
		$data['key'] = md5($data['name']);
		
		//条件
		$where = $this->key.'='.$id;
			
	
		return $this->where($where)->save($data);
	
	}
	/**
	 * 获取团队信息
	 * @param unknown $id
	 * @return Ambigous <mixed, boolean, NULL, multitype:, unknown, string>
	 */
	public function getRowById($id)
	{
		//字段
		$field = array(
				'*',
	
		);
	
		//条件
		$where = $this->key."=".$id;
	
		return $this->field($field)->where($where)->find();
	}
	/**
	 * 删除控制
	 * @param unknown $id
	 * @return Ambigous <mixed, boolean, false, number>
	 */
	public function del($id)
	{
			
		//单选
		if ( !is_array($id) )
		{
	
			return $this->delete($id);
		}
		//多选
		else
		{
	
			$idStr = implode(',', $id);
			//die($idStr);
			return $this->where("id in (".$idStr.")")->delete();
	
		}
			
	}
}


?>